package info.openlvb.openface.client.base.person;

import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.event.logical.shared.OpenHandler;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class PersonFunctionsPanel extends VerticalPanel {

	DisclosurePanel listPerson, addPerson;
	ListPersonPanel listPersonPanel;
	
	public PersonFunctionsPanel(){
		addPerson = new DisclosurePanel("Ajouter un utilisateur");
		addPerson.setAnimationEnabled(true);
		addPerson.setContent(new AddPersonPanel());
		listPerson = new DisclosurePanel("Lister les utilisateurs");
		listPerson.setAnimationEnabled(true);
		listPersonPanel = new ListPersonPanel();
		listPerson.setContent(listPersonPanel);
		
		addPerson.addOpenHandler(new OpenHandler<DisclosurePanel>() {
			public void onOpen(OpenEvent<DisclosurePanel> event) {
				listPerson.setOpen(false);
			}
		});
		listPerson.addOpenHandler(new OpenHandler<DisclosurePanel>() {
			public void onOpen(OpenEvent<DisclosurePanel> event) {
				addPerson.setOpen(false);
				listPersonPanel.refresh();
			}
		});
		
		add(addPerson);
		add(listPerson);
	}
}
